package com.bhs.sansonglogistics.ui.mine;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.net.Config;
import com.bhs.sansonglogistics.ui.other.WebViewActivity;

/**
 * 二级页面
 */
public class SecondaryPageActivity extends BaseActivity implements View.OnClickListener {


    private LinearLayout mLlBusinessLicense;
    private LinearLayout mLlAppreciation;
    private LinearLayout mLlUserAgreement;
    private LinearLayout mLlPrivacyAgreement;

    private int type;//1协议 2资质
    private LinearLayout mLlTransportationAgreement;
    private LinearLayout mLlEnterAgreement;

    @Override
    public int initLayout() {
        return R.layout.activity_secondary_page;
    }

    @Override
    public void initView() {
        type = getIntent().getIntExtra("type", 0);
        TextView mTvTitle = findViewById(R.id.tv_title);
        mTvTitle.setText("隐私和用户协议");
        mLlBusinessLicense = findViewById(R.id.ll_business_license);
        mLlAppreciation = findViewById(R.id.ll_appreciation);
        mLlUserAgreement = findViewById(R.id.ll_user_agreement);
        mLlPrivacyAgreement = findViewById(R.id.ll_privacy_agreement);

        mLlBusinessLicense.setOnClickListener(this);
        mLlAppreciation.setOnClickListener(this);
        mLlUserAgreement.setOnClickListener(this);
        mLlPrivacyAgreement.setOnClickListener(this);
        mLlTransportationAgreement = findViewById(R.id.ll_transportation_agreement);
        mLlEnterAgreement = findViewById(R.id.ll_enter_agreement);
        mLlTransportationAgreement.setOnClickListener(this);
        mLlEnterAgreement.setOnClickListener(this);
    }

    @Override
    public void initData() {
        if (type == 1) {
            mLlBusinessLicense.setVisibility(View.GONE);
            mLlAppreciation.setVisibility(View.GONE);
        } else {
            mLlUserAgreement.setVisibility(View.GONE);
            mLlPrivacyAgreement.setVisibility(View.GONE);
        }
    }

    @SuppressLint("NonConstantResourceId")
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_business_license:
                break;
            case R.id.ll_appreciation:
                break;
            case R.id.ll_user_agreement:
                startActivity(new Intent(mActivity, WebViewActivity.class)
                        .putExtra("url", Config.getUserProtocolUrl())
                        .putExtra("title", "用户协议"));
                break;
            case R.id.ll_privacy_agreement:
                startActivity(new Intent(mActivity, WebViewActivity.class)
                        .putExtra("url", Config.getPrivacyPolicyUrl())
                        .putExtra("title", "隐私协议"));
                break;
            case R.id.ll_transportation_agreement:
                startActivity(new Intent(mActivity, WebViewActivity.class)
                        .putExtra("url", Config.getTransportationUrl())
                        .putExtra("title", "运输协议"));
                break;
            case R.id.ll_enter_agreement:
                startActivity(new Intent(mActivity, WebViewActivity.class)
                        .putExtra("url", Config.getEnterUrl())
                        .putExtra("title", "入驻协议"));
                break;
        }
    }
}